<% layout('/layouts/default.html', {title: '预约管理', libs: ['validate','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-trophy"></i> ${text('查看预约')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${appointment}" action="${ctx}/fl/appointment/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}-${appointment.no}</div>

				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('预约人')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${appointment.leaguer.name}
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('地区')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${appointment.area.areaName}
							</div>
						</div>
					</div>
					
				</div>
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('诊所')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${appointment.clinic.name}
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('科室')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${@DictUtils.getDictLabel('fl_department', appointment.department, '未知')}
							</div>
						</div>
					</div>
					
				</div>			
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('预约日期')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${@DateUtils.formatDate(appointment.scheduledTime)}
							</div>
						</div>
					</div>
				
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('时间片')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${appointment.timePeriod}
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('预约状态')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${@DictUtils.getDictLabel('fl_appointment_status', appointment.appointmentStatus, '未知')}
							</div>
						</div>
					</div>			
				
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								 ${text('医生')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${appointment.doctor==null?"":appointment.doctor.name}
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								 ${text('理由')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${@DictUtils.getDictLabel('fl_reasons', appointment.reason, '未知')}
							</div>
						</div>
					</div>
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-3" title="">
								${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-9">
								${appointment.remarks}
							</div>
						</div>
					</div>
				</div>
				<h4 class="form-unit">${text('操作列表')}</h4>
				<div class="ml10 mr10">
					<table id="itemsDataGrid"></table>
						
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-9">
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
//初始化测试数据子表DataGrid对象
$("#itemsDataGrid").dataGrid({

	data: ${toJson(recordList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
		{header:'${text('操作')}', name:'action', width:150},
		{header:'${text('操作内容')}', name:'content', width:150},
		{header:'${text('预约号')}', name:'appointment.no', width:150},
		{header:'${text('理由')}', name:'reason', width:150, formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('fl_reasons')}, val, '', true);
		}},
		{header:'${text('操作时间')}', name:'createDate', width:150},
		{header:'${text('操作人')}', name:'createBy', width:150},
	],
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
	}
});
</script>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>
